﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern.MementoPattern
{
    //发起人，用来创建备忘录
    public class Originator
    {
        private string state;
        public string State
        {
            get { return state; }
            set { state = value; }
        }
        //创建备忘录
        public Memento CreateMemento()
        {
            return new Memento(state);
        }
        public void SetMemento(Memento memento)
        {
            state = memento.State;
        }

        public void Show()
        {
            Console.WriteLine("State:{0}", State);
        }
    }
}
